from app.app import Flask


def register_blueprint(app):
    from app.api.v1 import create_blueprint
    bp_v1 = create_blueprint()
    app.register_blueprint(bp_v1)


def register_plugin(app):
    from app.models.book import db
    db.init_app(app)


def create_app():
    app = Flask(__name__)
    app.config.from_object('app.config.setting')
    app.config.from_object('app.config.secure')

    register_blueprint(app)
    register_plugin(app)
    return app